package com.wudi.estate.service.impl.homemanage;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wudi.estate.bean.homemanage.Home;
import com.wudi.estate.mapper.homemanage.HomeMapper;
import com.wudi.estate.service.homemanage.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HomeServiceImpl implements HomeService {
    @Autowired
    private HomeMapper homeMapper;

    @Override
    public List<Home> selectList() throws Exception {
        return homeMapper.selectList(null);
    }

    @Override
    public Home selectById(long id) throws Exception {
        return homeMapper.selectById(id);
    }

    @Override
    public void insertName(String hname) throws Exception {
        Home home =new Home();
        home.setName(hname);
        homeMapper.insert(home);
    }

    @Override
    public Home selectByName(String hname) throws Exception {
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.eq("name",hname);
        return homeMapper.selectOne(queryWrapper);

    }

    @Override
    public void updateById(long hid,String hname) throws Exception {
        Home home = new Home();
        home.setId(hid);
        home.setName(hname);
        homeMapper.updateById(home);
    }
}
